/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意：
* 本软件为www.yixiang.co开发研制，未经购买不得使用
* 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
* 一经发现盗用、分享等行为，将追究法律责任，后果自负
*/
package co.yixiang.modules.product.service.mapper;

import co.yixiang.common.mapper.CoreMapper;
import co.yixiang.modules.product.domain.YxPrizeRecord;
import co.yixiang.modules.product.service.dto.YxPrizeRecordQueryVo;
import co.yixiang.modules.user.vo.BillVo;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* @author lsh
* @date 2021-10-21
*/
@Repository
public interface YxPrizeRecordMapper extends CoreMapper<YxPrizeRecord> {

    @Select("<script> select a.*,b.real_name,b.phone as userPhone,CONCAT(b.province,b.city,b.district,b.detail) as userAddress " +
            "from yx_prize_record a left join yx_user_address b on b.uid=a.uid  where b.is_default =1  "  +
            "<if test =\"phone !=''\">and b.phone  LIKE CONCAT('%',#{toPhone},'%')</if> " +
            "<if test =\"uid !=null\">and a.uid=#{uid}</if> " +
            "<if test =\"nickname !=''\">and a.nickname LIKE CONCAT('%',#{nickname},'%')</if> order by a.create_time desc </script> ")
    List<YxPrizeRecordQueryVo> queryAll( @Param("uid") Long uid,@Param("nickname") String nickname,   @Param("phone") String phone);

    @Select("SELECT * " +
            " FROM yx_prize_record ${ew.customSqlSegment}")
    List<YxPrizeRecord> getPrizeRecordList(@Param(Constants.WRAPPER) Wrapper<YxPrizeRecord> userWrapper, Page page);
}
